package com.cheung.leetcode.dp;

import org.junit.jupiter.api.Test;

/**
 * @BelongsProject : java-leetcode
 * @BelongsPackage : com.cheung.leetcode.dp
 * @Author :  cheungming
 * @CreateTime : 2024-06-15 09:27:21
 * @Description : 零钱兑换 II
 * @Version : 1.0
 */
public class Code518Test {

    public int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int coin : coins) {
            for (int i = coin; i <= amount; i++) {
                dp[i] += dp[i - coin];
            }
        }

        return dp[amount];
    }

    @Test
    public void test1() {
        assert change(5, new int[]{1, 2, 5}) == 4;
    }

    @Test
    public void test2() {
        assert change(3, new int[]{2}) == 0;
    }


}
